package com.zl.zlproject.splash;

import android.animation.ValueAnimator;
import android.content.Intent;
import android.widget.TextView;

import com.zl.zlproject.R;
import com.zl.zlproject.base.activity.BaseActivity;
import com.zl.zlproject.ui.main.MainActivity;

import butterknife.BindView;

/**
 * Created by 郑磊 on 2018/6/19.
 */

public class SplashActivity extends BaseActivity {


    @BindView(R.id.tv)
    TextView mTv;

    @Override
    protected int getContentViewRes() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initData() {
        super.initData();

        ValueAnimator animator = ValueAnimator.ofInt(2, 0);
        animator.setDuration(2000L);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int animatedValue = (int) animation.getAnimatedValue();
                mTv.setText(animatedValue+"");
                if(animatedValue == 0){
                    startActivity(new Intent(SplashActivity.this, MainActivity.class));
                }
            }
        });
        animator.start();
    }


}
